package com.qfedu.yanglao20admin.scoreManager.controller;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.qfedu.yanglao20.common.CommonResult;
import com.qfedu.yanglao20.common.param.PageParam;
import com.qfedu.yanglao20admin.health.entity.HealthData;
import com.qfedu.yanglao20admin.scoreManager.entity.ScoreManager;
import com.qfedu.yanglao20admin.scoreManager.param.ScoreManagerParam;
import com.qfedu.yanglao20admin.scoreManager.service.ScoreManagerService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;

/**
 * (ScoreManager)表控制层
 *
 * @author makejava
 * @since 2023-04-24 17:14:28
 */
@Api(tags = "分数信息管理")
@RestController
@RequestMapping("scoreManager")
public class ScoreManagerController {
    /**
     * 服务对象
     */
    @Resource
    private ScoreManagerService scoreManagerService;


    /**更具数据类型获取数据
     *
     * @param
     * @return
     */
    @ApiOperation(value = "根据id查询数据", notes = "根据id查询数据")
    @GetMapping("{id}")
    public ResponseEntity<ScoreManager> queryBydata(@PathVariable("id") Integer id) {
        return ResponseEntity.ok(this.scoreManagerService.queryid(id));
    }

    @ApiOperation(value = "更具数据类型删除数据", notes = "更具数据类型删除数据")
    @GetMapping("/delete")
    public CommonResult deletescoreManage(@RequestParam @ApiParam("分值里的id") Integer id) {
        scoreManagerService.deleteByid(id);
        return CommonResult.success();
    }
    @ApiOperation(value = "添加分值信息", notes = "添加分值信息")
    @PostMapping("/insert")
    public void insert(ScoreManager scoreManager){
        scoreManagerService.insertScore(scoreManager);
    }


    /**
     * 分页查询
     *
     * @param
     * @param
     * @return 查询结果
     */

    @ApiOperation(value = "分页展示分数信息", notes = "分页展示分数信息")
    @GetMapping("/page")
    public CommonResult<ScoreManager> page(ScoreManagerParam param) {
        Page<ScoreManager> scoreManagerPage = scoreManagerService.pagescore(param);
        return CommonResult.success(scoreManagerPage);
    }

    @ApiOperation(value = "编辑分数信息", notes = "编辑分数信息")
    @PostMapping("/update")
    public void  update(ScoreManager scoreManager){
         scoreManagerService.updateScore(scoreManager);
    }

    @ApiOperation(value = "根据数据类型查询数据", notes = "根据数据类型查询数据")
    @PostMapping("/querydata")
    public ScoreManager querydata(String data){
        return scoreManagerService.queryBydata(data);
    }
}

